package xyz.wadewhy.basicstest.designPatterns.BuilderPattern;

/**
 * @ClassName ProductBase
 * @Description 商品基础属性
 * @Author zhongzihao
 * @Date 2021/12/24 12:57 下午
 * @Version 1.0
 **/
abstract class ProductBase {
    /**
     * 名称
     */
    abstract void getName(ProductTypeEnum type);

    /**
     * 获得点卷
     *
     * @param expirationTime 到期时间
     */
    abstract void couponExpiration(Long expirationTime);

    /**
     * 视频url
     */
    abstract void urlLock();
}

class NormalProduct extends ProductBase {

    @Override
    void getName(ProductTypeEnum type) {
        System.out.println("获得.." + type.getValue());
    }

    @Override
    void couponExpiration(Long expirationTime) {
        System.out.println("卡劵剩余时间.." + expirationTime);
    }

    @Override
    void urlLock() {
        System.out.println("普通商品未解锁..");
    }
}

class VipProduct extends ProductBase {

    @Override
    void getName(ProductTypeEnum type) {
        System.out.println("获得.." + type.getValue());
    }

    @Override
    void couponExpiration(Long expirationTime) {
        System.out.println("VIP卡劵剩余时间.." + expirationTime);
    }

    @Override
    void urlLock() {
        System.out.println("已付款，解锁..");
    }

    void vipBusiness(){
        System.err.println("vip商品自己的业务场景");
    }
}

enum ProductTypeEnum {
    /**
     *
     */
    NORMAL(1, "普通商品"),
    /**
     *
     */
    VIP(2, "VIP商品");

    /**
     * code
     */
    private int code;
    /**
     * value
     */
    private String value;

    ProductTypeEnum(int code, String value) {
        this.code = code;
        this.value = value;
    }

    ProductTypeEnum() {
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
